from PySide6.QtWidgets import QApplication, QPushButton, QMainWindow
from PySide6.QtCore import Slot

import datetime

@Slot()
def on_click():
    # 用户的点击事件，点击后执行
    print(datetime.datetime.now(), '用户点击来了按钮')


app = QApplication()

window = QMainWindow()  # 创建主窗口


btn = QPushButton("我是一个按钮", parent=window)

btn.resize(400, 270)
# btn.show()  # 显示元素
btn.clicked.connect(on_click)

window.show()  # 显示窗口

app.exec()